package com.bringway.p2p.controller;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.bringway.framework.controller.JsonController;
import com.bringway.framework.excel.ExcelOperUtil;
import com.bringway.framework.excel.ExcelSheet;
import com.bringway.framework.util.DateUtils;
import com.bringway.framework.util.RequestUtils;
import com.bringway.p2p.service.XtdlrzService;
/**
 * 
 * @author qjy
 * @version 创建时间：2016年06月14日 上午13:15:42
 * @功能：异常查询
 */
@Controller
@RequestMapping("/xtdlrz")
public class XtdlrzController  extends JsonController {
	
	@Autowired
	private XtdlrzService xtdlrzService;
	/**
	 * 
	 * @param request
	 * @param response 查询数据
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/queryXtdlrzList")
	public ModelAndView queryXtdlrzList(HttpServletRequest request,HttpServletResponse response) throws Exception{
		JSONObject result = new JSONObject();
		JSONObject params = new JSONObject();
		
		Integer start = RequestUtils.getIntParameter(request, "start");
		Integer limit = RequestUtils.getIntParameter(request, "limit");
		
		String name= RequestUtils.getStringParameter(request, "name");
		String sjhm= RequestUtils.getStringParameter(request, "sjhm");
		
	
		params.put("start", start);
		params.put("limit", limit);
		
		params.put("name", name);
		params.put("sjhm", sjhm);
	
		List<Map<String, Object>> list = xtdlrzService.queryXtdlrzList(params);
		int count = xtdlrzService.gettXtdlCount(params);
		result.put("data", list);	
		result.put("total", count);
		serialize(request,response,result);
		return null;
	}
	
	
	
	
	/*
	*//**
	 * 
	 * @param request
	 * @param response
	 * @return  导出excel表格
	 * @throws Exception
	 *//*
	@RequestMapping("exportYcxiExcelMethod")
	public ModelAndView exportYcExcelMethod(HttpServletRequest request, HttpServletResponse response) throws Exception{
		JSONObject params = new JSONObject();
		Integer start = RequestUtils.getIntParameter(request, "start");
		Integer limit = RequestUtils.getIntParameter(request, "limit");
	
		String yhm= RequestUtils.getStringParameter(request, "USER_NAME");
		String username= RequestUtils.getStringParameter(request, "USER_NAME");
		String cwm= RequestUtils.getStringParameter(request, "LOG_TYPE");
		String cwxi= RequestUtils.getStringParameter(request, "LOG_CONTENT");
		String cwtime= RequestUtils.getStringParameter(request, "LOG_DATE");
		
		params.put("start", start);
		params.put("limit", limit);
		params.put("yhm", yhm);
		params.put("username", username);
		params.put("startDate", startDate);
		params.put("endDate", endDate);
		params.put("cwm", cwm);
		params.put("cwxi", cwxi);
		params.put("cwtime", cwtime);
		
		
		// 查询数据
		List<Map<String, Object>> list =ycxiService.queryYcxiList(params);
		List<String[]> dataList = com.bringway.p2p.constant.ExcelHeadConstant.getYcExportSearchResultData(list);
		
		// 导出数据到Excel文件
		List<ExcelSheet> sheetList = new ArrayList<ExcelSheet>();
		ExcelSheet sheet = new ExcelSheet();
		sheet.setBodyList(dataList);
		sheet.setSheetName(DateUtils.getCurrentDataStr()+"系统信息明细");
		sheetList.add(sheet);
		OutputStream os = response.getOutputStream();
		String fileName = DateUtils.getCurrentDataStr() + "系统信息明细.xls";
		super.setDownLoadResponseHeader(request, response, fileName);
		response.setContentType("application/vnd.ms-excel");
		
		// 导出EXCEL
		
		ExcelOperUtil.writeExcel(sheetList, os);
		return null;
	}*/
	

	
	
}
